<%= form_for @user do |f| %>
  <div class="field">
    <%= f.label :email, "Email" %><br>
    <%= f.email_field :email %>
  </div>

  <div class="field">
    <%= f.label :name, "Nome completo" %><br>
    <%= f.text_field :name %>
  </div>

  <div class="field">
    <%= f.label :username, "Nome de usuário" %><br>
    <%= f.text_field :username %>
  </div>

  <div class="field">
    <%= f.label :password, "Senha" %><br>
    <%= f.password_field :password %>
  </div>

  <div class="field">
    <%= f.label :active, "Ativo" %><br>
    <%= f.check_box :active %>
  </div>

  <div class="group_users">
    <h3>Grupos</h3>

    <%= f.fields_for :group_users do |b| %>
      <%= render 'group_user_fields', f: b %>
    <% end %>

    <div class="links">
      <%= link_to_add_association 'Adicionar grupo', f, :group_users %>
    </div>
  </div>

  <div class="actions">
    <%= f.submit %><br>
    or <%= link_to :cancel, users_path %>
  </div>
<% end %>
